package com.his.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.his.admin.service.RoleInterfaceService;
import com.his.dao.domain.dto.SelectRoleInterfaceDto;
import com.his.dao.domain.vo.SelectAllVo;
import com.his.util.entity.RoleInterface;
import com.his.util.mapper.RoleInterfaceMapper;
import com.his.util.result.RestResult;
import com.his.util.result.RestResultBuilder;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class RoleInterfaceServiceImpl extends ServiceImpl<RoleInterfaceMapper, RoleInterface> implements RoleInterfaceService {
    private RoleInterfaceMapper roleInterfaceMapper;

    @Override
    public RestResult all(SelectRoleInterfaceDto selectRoleInterfaceDto) {
        return new RestResultBuilder().success(SelectAllVo
                .builder()
                .list(roleInterfaceMapper.selectAll(
                        selectRoleInterfaceDto.getRoleId(),
                        selectRoleInterfaceDto.getName(),
                        selectRoleInterfaceDto.getPage() * selectRoleInterfaceDto.getPageSize(),
                        selectRoleInterfaceDto.getPageSize()))
                .total(roleInterfaceMapper.selectAllCount(
                        selectRoleInterfaceDto.getRoleId(),
                        selectRoleInterfaceDto.getName()))
                .build());
    }
}
